//package com.peng.my_blog.util;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.fasterxml.jackson.databind.JavaType;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.peng.my_blog.entity.Article;
//import redis.clients.jedis.Jedis;
//import redis.clients.jedis.JedisPool;
//import redis.clients.jedis.JedisPoolConfig;
//
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//
//public class RedisPool {
//
//    private static JedisPool pool;//jedis 连接池
//    private static Integer maxTotal=Integer.valueOf(PropertiesUtil.getProperty("redis.max.total"));//最大连接数
//    private static Integer maxIdle=Integer.valueOf(PropertiesUtil.getProperty("redis.max.idle"));//最大空闲实例
//    private static Integer minIdle=Integer.valueOf(PropertiesUtil.getProperty("redis.min.idle"));//最大空闲实例
//    private static Boolean testOnBorrow = Boolean.getBoolean(PropertiesUtil.getProperty("redis.test.borrow"));//取实例时是否需要验证实例可用
//    private static Boolean testOnReturn =Boolean.getBoolean(PropertiesUtil.getProperty("redis.test.return")); //放回实例时是否需要验证实例可用
//    private static String ip = PropertiesUtil.getProperty("redis.ip");
//    private static Integer port = Integer.valueOf(PropertiesUtil.getProperty("redis.port"));
//
//    static {
//        initPool();
//    }
//
//
//    private static void initPool(){
//        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
//        jedisPoolConfig.setMaxTotal(maxTotal);
//        jedisPoolConfig.setMaxIdle(maxIdle);
//        jedisPoolConfig.setMinIdle(minIdle);
//        jedisPoolConfig.setTestOnBorrow(testOnBorrow);
//        jedisPoolConfig.setTestOnReturn(testOnReturn);
//
//        jedisPoolConfig.setBlockWhenExhausted(true);//连接耗尽时，是否阻塞 false会抛出异常 ture阻塞到超时，默认为true
//
//        pool = new JedisPool(jedisPoolConfig,ip,port,1000*2);
//
//
//    }
//
//
//    public static Jedis getJedis(){
//        return pool.getResource();
//    }
//
//    public static void returnBrokenResource(Jedis jedis){
//        pool.returnBrokenResource(jedis);
//    }
//
//    public static void returnResource(Jedis jedis){
//        pool.returnResource(jedis);
//    }
//
//    public static void main(String[] args) throws IOException {
////        Jedis jedis = RedisPool.getJedis();
////        jedis.set("newKey","newVal");
////        RedisPool.returnResource(jedis);
//        ObjectMapper objectMapper = new ObjectMapper();
//
//
//
//
//
//    }
//
//
//}
